
const db = require("../db/index")


const getUserPermission = (req, res) => {
    //mg_name
    let sql = "select ps_ids from sp_manager,sp_role where sp_manager.role_id=sp_role.role_id and mg_name=?"
    // db.query(sql, req.query.mg_name, (err, result) => {
    db.query(sql, req.user.mg_name, (err, result) => {
        if (err) return res.sendErr(err)
        let resArr = result[0].ps_ids === '' ? [] : result[0].ps_ids.split(',')
        // console.log(resArr);
        res.send({
            status: 200,
            message: "获取权限id成功!",
            data: resArr,
        })
    })
}

module.exports = {
    getUserPermission
}